{% extends "metasearch/base.html" %}

{% load staticfiles %}

{% block metadescription %}Results for {{ raw_query }} (Aggregated){% endblock %}

{% block title %}
    Results for "{{ raw_query }}" (Aggregated) -- MetaSearch
{% endblock %}

{% block content %}
  <form id="form_search" class="container results" action="" method="get">
    <div class="row" id="row_input_query">
      <img src="{% static 'metasearch/images/logo_small.png' %}" id="logo_small" class="img-responsive col-xs-3" alt="MetaSearch" />
      <input type="text" name="query" id="input_query" class="col-xs-5 col-xs-offset-4 col-md-5 col-md-offset-4" 
        value="{{ raw_query }}" maxlength="100" placeholder="Enter your query here" />
      <input type="submit" id="button_search" class="btn btn-lg btn-primary col-xs-2 col-xs-offset-1 col-md-2 col-md-offset-1" value="Search" />
    </div>

    <div class="row" id="checkboxes">
      <input type="checkbox" name="bing" id="box_bing" {% if show_bing %}checked="checked" {% endif %}/><label for="box_bing">Bing</label>
      <input type="checkbox" name="blekko" id="box_blekko" {% if show_blekko %}checked="checked" {% endif %}/><label for="box_blekko">Blekko</label>
      <!-- EntireWeb is temporarily disabled as its API is not available occasionally -->
      <input type="checkbox" name="entweb" id="box_entweb" {% if show_entweb %}checked="checked" {% endif %} title="Currently Disabled" disabled /><label for="box_entweb">EntireWeb</label><br />
    </div>

    <div class="row" id="selects">
      <select name="aggr" id="select_aggr">
        <option value="false">Non-Aggregated</option>
        <option value="true" selected="selected">Aggregated</option>
      </select>
      <select name="cluster" id="select_cluster">
        <option value="false" {% if not cluster %}selected="selected"{% endif %}>Non-Clustered</option>
        <option value="true" {% if cluster %}selected="selected"{% endif %}>Clustered</option>
      </select>
    </div>
  </form>
  <br />  
  <div class="pagelist" align="center">
  {% for page in page_list %}
    <a href="{{ full_path }}&page={{ page }}">
    {% if page == current_page %}
        <b>[{{ page }}]</b>
    {% else %}
        {{ page }}
    {% endif %}
    </a>&nbsp;&nbsp;&nbsp;
  {% endfor %}
  </div><br />
  <div class="itemlist">
  {% if cluster %}
    {% for cluster in clusters %}
      <p><b>Cluster {{ forloop.counter }}</b></p>
      <ul>
      {% for i in cluster%}
        <li class="item">{{ forloop.counter }} -- <a href="{{ i.url }}" target="_blank">{{ i.title|safe }}</a>
        {% for s in i.source %}
          &nbsp;<img src="/static/metasearch/images/{{s}}_small.png" alt="{{ s }}" />&nbsp;
        {% endfor %}<br />
        <span class="displayurl">{{ i.displayurl|safe }}</span><br />
        <p>{{ i.snippet|safe }}</p>
        </li>
      {% endfor %}
      </ul>
    {% empty %}
      <p class="error" align="center">No content available.</p>
    {% endfor %}
  {% else %}
    <ul>
    {% for i in result_list%}
      <li class="item">{{ forloop.counter }}--<a href="{{ i.url }}" target="_blank">{{ i.title|safe }}</a>
      {% for s in i.source %}
        &nbsp;<img src="/static/metasearch/images/{{s}}_small.png" alt="{{ s }}" />&nbsp;
      {% endfor %}<br />
      <span class="displayurl">{{ i.displayurl|safe }}</span><br />
      <p>{{ i.snippet|safe }}</p>
      </li>
    {% empty %}
      <p class="error" align="center">No content available.</p>
    {% endfor %}
    </ul>
  {% endif %}
  </div><br />
  <div class="pagelist" align="center">
  {% for page in page_list %}
    <a href="{{ full_path }}&page={{ page }}">
    {% if page == current_page %}
      <b>[{{ page }}]</b>
    {% else %}
      {{ page }}
    {% endif %}
    </a>&nbsp;&nbsp;&nbsp;
  {% endfor %}
  </div><br />
{% endblock %}
